<%--
  Created by IntelliJ IDEA.
  User: fengdefangxiang
  Date: 2022/1/17
  Time: 11:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <title>修改信息</title>
    <%@ include file="/web/header.jsp"%>
</head>
<body>
<fieldset class="layui-elem-field" style="margin: 20px;padding: 15px">
    <legend>修改信息</legend>
        <form class="layui-form layui-form-pane" lay-filter="formA" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label" readonly>编号</label>
                <div class="layui-input-inline">
                    <input type="text" name="code" required lay-verify="required" placeholder="请输入编号" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" placeholder="请输入名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="button" value="修改" class="layui-btn" lay-submit lay-filter="upd">
                    <input type="reset" class="layui-btn layui-btn-primary">
                    <input type="button" value="关闭" class="layui-btn" onclick="layerClose()">
                </div>
            </div>
            <input type="hidden" name="action" value="upd">
        </form>
</fieldset>
<script type="text/javascript">
    var code = '<%=request.getParameter("code")%>';
    function init(){
        ajax('/EmployeeServlet',{code:code,action:'get'},'json',function (data){
            // 回显
            // $("input[name='code']").val(data.code)
            // $("input[name='name']").val(data.name)
            // $("input[name='tel']").val(data.tel)
            //form.val('formA',{code:data.code,name:code.name,tel:code.tel});  两种回显的方法
            form.val('formA',data)
        })
    }
    init();
    formOnSubmit('upd','/EmployeeServlet','text',function (data){
        if (data == 1) {
            layer.msg("修改成功",layerClose); // 修改成功后要加回调函数，因为成功后要关闭
        }else {
            layer.msg("修改失败");
        }s
    })

</script>
</body>
</html>
